#include<bits/stdc++.h>
#define int long long
#define lowbit(x) (x&-x)
using namespace std;
const int N=1e5+10;
int n,k,a[N],b[N],t[N];
inline void upd(int x,int y){
	for(;x<=n;x+=lowbit(x))
		t[x]=max(t[x],y);
}
inline int qry(int x){
	int res=-1e9;
	for(;x;x-=lowbit(x))
		res=max(res,t[x]);
	return res;
}
inline int check(int x){
	int ans=0;
	for(int i=1;i<=n;i++){
		for(int j=0;j<=n;j++)
			t[j]=-1e9;
		upd(a[i],1);
		for(int j=i-1;j>=1;j--){
			if(b[a[j]]>x) continue;
			int res=qry(upper_bound(b+1,b+n+1,x-b[a[j]])-b-1)+1;
			if(b[a[j]]+b[a[i]]<=x) ans=max(ans,res);
			upd(a[j],res);
		}
	}
	return ans;
}
signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0),cout.tie(0);
	freopen("sub.in","r",stdin);
	freopen("sub.out","w",stdout);
	cin>>n>>k;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		b[i]=a[i];
	}
	sort(b+1,b+n+1);
	for(int i=1;i<=n;i++)
		a[i]=lower_bound(b+1,b+n+1,a[i])-b;
	int l=1,r=2e9,res=2e9;
	while(l<=r){
		int mid=(l+r)>>1;
		if(check(mid)>=k) r=mid-1,res=mid;
		else l=mid+1;
	}
	cout<<res;
	return 0;
}
